package cn.jiahua.test13;

import java.util.concurrent.CountDownLatch;

//计数器
public class Test {
    /**
     * 线程计数器
     * @param args
     */
    public static void main(String[] args) {

        //酒楼，等人吃饭，人齐之后在吃饭，6人
        CountDownLatch countDownLatch=new CountDownLatch(7);


        for (int i=1;i<=6;i++){
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"达到酒楼了");
                countDownLatch.countDown();//减1 签到
            }).start();
        }
        try {
            countDownLatch.await();  //阻塞
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("人齐了开饭！");
    }



}
